package com.example.electronicmall.controller;

import java.util.Arrays;
import java.util.Map;

import com.example.electronicmall.config.Constant;
import com.example.electronicmall.entity.UserEntity;
import com.example.electronicmall.service.UserService;
import com.example.electronicmall.to.UserTo;
import com.example.electronicmall.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;


/**
 * @author mwh
 * @email 1062966353@qq.com
 * @date 2022-12-02 14:48:53
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/register")
    public R register(UserTo userTo){
        userService.register(userTo);
        return R.ok().setData("注册成功");
    }

    @PostMapping("/login")
    public UserEntity login(String username, String password){
        return userService.login(username, password);
    }
}
